package swe.article;

public enum Category {
	
	 KLEINWAGEN("Kleinwagen",1), KOMBI("Kombi",2), SUV("SUV",3);
	 
	 private int id;
	 private String name;
	 
	 private Category(String name,int c) {
		 this.name = name;
		 id = c;
	 }
	 
	 public int getId() {
	   return id;
	 }
	 
	 public String getName() {
		   return name;
	 }
	 
	 public static Category[] getCategories() {
		 return values();
	 }
	 
	 public static String getNameFromId(int id) {
		 for(Category c: getCategories()) {
			 if(c.getId() == id)
				 return c.getName();
		 }
		 return "";
	 }
	 
	 public static Category getCategoryFromId(int id) {
		 for(Category c: getCategories()) {
			 if(c.getId() == id)
				 return c;
		 }
		 return Category.KLEINWAGEN;
	 }
}
